﻿using Flame.Reflection;
using System;
using System.Collections.Generic;
using System.Text;

namespace Flame.Dlr
{
    public class ExceptionExec : Exception, IExecutable
    {
        string _name;
        string _messageCause = null;
        public ExceptionExec(string name)
        {
            _name = name;
        }

        public ExceptionExec(string name, Exception e)
        {
            _name = name;
            _messageCause = e.Message;
        }

        public Result Execute(string text)
        {
            if(_messageCause == null) 
                return new Result() { Data = new FlameException(_name.ToString() + " not available") };
            else
                return new Result() { Data = new FlameException(_name.ToString() + " not available" + Environment.NewLine + _messageCause) };
        }


        public void AddVariable(Variable variable) { }
        public void ClearScope(ScopeParameters scopeParameters) { }

        public ResultAssembly AddAssembly(AssemblyWrapper ainfo)
        {
            return new ResultAssembly() { Exception = new FlameException(_name.ToString() + " not available"), Loaded = false, Language = GetType() };
        }

        public IIntellisense Intellisense { get { return null; } }
    }
}
